`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Module: AUDIO_LED                                                            //
// Author: Zhiyuan Lin                                                          //
// Date: 3/30/2014                                                              //
// Description: This module is to light the LED according to the rythm.         //
//////////////////////////////////////////////////////////////////////////////////
module AUDIO_LED(clk_4Hz, tone, seg_r);          
    input clk_4Hz;
    input [4:0] tone;	 
    output reg [7:0] seg_r;

always @(posedge clk_4Hz)
  begin
case(tone) 

// for low1 to low7
  1: 
  begin 
  seg_r <= 8'h01; 
  end //low1
  2: 
  begin 
  seg_r <= 8'h02; 
  end //low1#
  3: 
  begin 
  seg_r <= 8'h03; 
  end //low2
  4:
  begin 
  seg_r <= 8'h04; 
  end //low2#
  5:
  begin 
  seg_r <= 8'h05; 
  end //low3
  6:
  begin 
  seg_r <= 8'h06;
  end //low4
  7:
  begin 
  seg_r <= 8'h07; 
  end //low4#
  8:
  begin 
  seg_r <= 8'h08;
  end //low5
  9: 
  begin 
  seg_r <= 8'h09; 
  end //low5#
  10: 
  begin 
  seg_r <= 8'h0a; 
  end //low6
  11: 
  begin 
  seg_r <= 8'h0b; 
  end //low6#
  12: 
  begin 
  seg_r <= 8'h0c; 
  end //low7
  
// for middle1 to middle7
  13: 
  begin 
  seg_r <= 8'h0d; 
  end //middle1
  14: 
  begin 
  seg_r <= 8'h0e; 
  end //middle1#
  15: 
  begin 
  seg_r <= 8'h0f; 
  end //middle2
  16:
  begin 
  seg_r <= 8'h1f; 
  end //middle2#
  17:
  begin 
  seg_r <= 8'h2f; 
  end //middle3
  18:
  begin 
  seg_r <= 8'h3f;
  end //middle4
  19:
  begin 
  seg_r <= 8'h4f; 
  end //middle4#
  20:
  begin 
  seg_r <= 8'h5f;
  end //middle5
  21: 
  begin 
  seg_r <= 8'h6f; 
  end //middle5#
  22: 
  begin 
  seg_r <= 8'h7f; 
  end //middle6
  23: 
  begin 
  seg_r <= 8'h8f; 
  end //middle6#
  24: 
  begin 
  seg_r <= 8'h9f; 
  end //middle7
  
// for high1 to high7
  25: 
  begin 
  seg_r <= 8'haf; 
  end //high1
  26: 
  begin 
  seg_r <= 8'hbf; 
  end //high1#
  27: 
  begin 
  seg_r <= 8'hcf; 
  end //high2
  28:
  begin 
  seg_r <= 8'hdf; 
  end //high2#
  29:
  begin 
  seg_r <= 8'hef; 
  end //high3
  30:
  begin 
  seg_r <= 8'hff;
  end //high4
  31:
  begin 
  seg_r <= 8'hf1; 
  end //high4#
  32:
  begin 
  seg_r <= 8'hf2;
  end //high5
  33: 
  begin 
  seg_r <= 8'hf3; 
  end //high5#
  34: 
  begin 
  seg_r <= 8'hf4; 
  end //high6
  35: 
  begin 
  seg_r <= 8'hf5; 
  end //high6#
  36: 
  begin 
  seg_r <= 8'hf6; 
  end //high7
endcase
  end                               
endmodule